home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / src / dialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  2.5 KB  |  107 lines

  1. /* Dialog managing.
  2.    Copyright (C) 1994 Miguel de Icaza.
  3.    
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #include <config.h>
  19. #include "tty.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>    /* For free() */
  22. #include <stdarg.h>
  23. #include <sys/types.h>
  24. #include <string.h>
  25. #include "mad.h"
  26. #include "global.h"
  27. #include "util.h"
  28. #include "dialog.h"
  29. #include "color.h"
  30. #include "win.h"
  31. #include "mouse.h"
  32. #include "main.h"
  33. #include "key.h"    /* For mi_getch() */
  34. #include "dlg.h"    /* draw_box, yes I know, it's silly */
  35.  
  36. /* "$Id: dialog.c,v 1.15 1995/02/21 19:05:31 miguel Exp $" */
  37.  
  38. Refresh *refresh_list = 0;
  39.  
  40. void push_refresh (void (*new_refresh)(void *), void *parameter, int flags)
  41. {
  42.     Refresh *new;
  43.  
  44.     new = xmalloc (sizeof (Refresh), "push_refresh");
  45.     new->next = (struct Refresh *) refresh_list;
  46.     new->refresh_fn = new_refresh;
  47.     new->parameter = parameter;
  48.     new->flags     = flags;
  49.     refresh_list = new;
  50. }
  51.  
  52. void pop_refresh (void)
  53. {
  54.     Refresh *old;
  55.     
  56.     if (!refresh_list)
  57.     fprintf (stderr, "\n\n\nrefresh stack underflow!\n\n\n");
  58.     else {
  59.     old = refresh_list;
  60.     refresh_list = refresh_list->next;
  61.     free (old);
  62.     }
  63. }
  64.  
  65. static void do_complete_refresh (Refresh *refresh_list)
  66. {
  67. #ifndef HAVE_X
  68.     if (!refresh_list)
  69.     return;
  70.  
  71.     if (refresh_list->flags != REFRESH_COVERS_ALL)
  72.     do_complete_refresh (refresh_list->next);
  73.     
  74.     (*(refresh_list->refresh_fn))(refresh_list->parameter);
  75. #endif    
  76. }
  77.  
  78. void do_refresh (void)
  79. {
  80. #ifndef HAVE_X
  81.     if (!refresh_list)
  82.     return;
  83.     else {
  84.     if (fast_refresh)
  85.         (*(refresh_list->refresh_fn))(refresh_list->parameter);
  86.     else {
  87.         do_complete_refresh (refresh_list);
  88.     }
  89.     }
  90. #endif    
  91. }
  92.  
  93. /* Poor man's window puts, it doesn't handle auto-wrap */
  94. void my_wputs (int y, int x, char *text)
  95. {
  96.     char p;
  97.  
  98.     move (y, x);
  99.     while ((p = *text++) != 0){
  100.     if (p == '\n')
  101.         move (++y, x);
  102.     else 
  103.         addch (p);
  104.     }
  105. }
  106.  
  107.